home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1996 #1
/
Amiga Plus CD - 1996 - No. 1.iso
/
pd
/
grafik
/
dust_v2.34
/
batchfiles
/
starfield.bat
< prev
next >
Wrap
DOS Batch File
|
1995-09-28
|
3KB
|
164 lines
;create a starfield of tetraeders randomly scaled and rotated
;Dust 2.11 or higher required (because of the 'if'-constructs)
;
;--------------------------------------------------------
; public stuff
;--------------------------------------------------------
;particle-size
.size=2.0
;space-size
.rsize=100
;number of particles
.pnum=600
;random scale-value (1-ds) .. (1+ds)
.ds=0.2
;buffers
.src=1
.tmp1=12
.tmp2=13
.tmp3=14
.dest=2
;--------------------------------------------------------
set(echo,off)
;1. create a tetraeder
echo(--------------------------------------------------------)
echo("creating the source-object")
echo(--------------------------------------------------------)
.p1x=0
.p1y=0
.p1z=62
.p2x=62
.p2y=0
.p2z=-36
.p3x=-62
.p3y=0
.p3z=-36
.p4x=0
.p4y=86
.p4z=0
addface(src,p1x,p1y,p1z,p2x,p2y,p2z,p3x,p3y,p3z)
addface(src,p1x,p1y,p1z,p2x,p2y,p2z,p4x,p4y,p4z)
addface(src,p1x,p1y,p1z,p3x,p3y,p3z,p4x,p4y,p4z)
addface(src,p2x,p2y,p2z,p3x,p3y,p3z,p4x,p4y,p4z)
merge(src)
color(src,160,160,160)
spec(src,255,255,255)
hardness(src,255)
;load(1,<yourobject>)
;2. get the object-size (maybe you did load another object)
echo(--------------------------------------------------------)
echo("calculating object-size")
echo(--------------------------------------------------------)
fcount(src)
getpoint(src,0)
.xmin=px
.xmax=px
.ymin=py
.ymax=py
.zmin=pz
.zmax=pz
for(i,1,fcount-1)
getpoint(src,i)
if(px<xmin,.xmin=px)
if(px>xmax,.xmax=px)
if(py<ymin,.ymin=py)
if(py>ymax,.ymax=py)
if(pz<zmin,.zmin=pz)
if(pz>zmax,.zmax=pz)
end
echo(xmin=,xmin)
echo(xmax=,xmax)
echo(ymin=,ymin)
echo(ymax=,ymax)
echo(zmin=,zmin)
echo(zmax=,zmax)
;3. scaling the object
echo(--------------------------------------------------------)
echo("scaling the object")
echo(--------------------------------------------------------)
.xsize=xmax-xmin
.ysize=ymax-ymin
.zsize=zmax-zmin
if(xsize<ysize,.xsize=ysize)
if(xsize<zsize,.xsize=zsize)
.scl=size/xsize
scale(src,scl,x)
scale(src,scl,y)
scale(src,scl,z)
size(src)
;4. do it
.rs2=0-rsize*0.5
echo(--------------------------------------------------------)
echo("performing main-loop")
echo(--------------------------------------------------------)
copy(src,tmp3)
.scl=rnd(1000)/999*ds
if(rnd(2)=1,.scl=1+scl,.scl=1-scl)
scale(tmp3,scl,x)
scale(tmp3,scl,y)
scale(tmp3,scl,z)
rotate(tmp3,"rnd(360)",x)
rotate(tmp3,"rnd(360)",y)
rotate(tmp3,"rnd(360)",z)
.posx=rnd(1000)/999
.posx=rs2+posx*rsize
.posy=rnd(1000)/999
.posy=rs2+posy*rsize
.posz=rnd(1000)/999
.posz=rs2+posz*rsize
translate(tmp3,posx,x)
translate(tmp3,posy,y)
translate(tmp3,posz,z)
for(i,2,pnum)
echo(" object ",i)
copy(src,tmp1)
.scl=rnd(1000)/999*ds
if(rnd(2)=1,.scl=1+scl,.scl=1-scl)
scale(tmp1,scl,x)
scale(tmp1,scl,y)
scale(tmp1,scl,z)
rotate(tmp1,"rnd(360)",x)
rotate(tmp1,"rnd(360)",y)
rotate(tmp1,"rnd(360)",z)
.posx=rnd(1000)/999
.posx=rs2+posx*rsize
.posy=rnd(1000)/999
.posy=rs2+posy*rsize
.posz=rnd(1000)/999
.posz=rs2+posz*rsize
translate(tmp1,posx,x)
translate(tmp1,posy,y)
translate(tmp1,posz,z)
join(tmp3,tmp1,tmp2)
copy(tmp2,tmp3)
end
copy(tmp3,dest)
kill(src)
kill(tmp1)
kill(tmp2)
kill(tmp3)
;5. That's it
echo(--------------------------------------------------------)
echo("object can be found in layer ",dest)
echo(--------------------------------------------------------)
window(dest)
stats(dest)